<!DOCTYPE html>
{% load static %}
{% load ppp %}
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="icon" href="{% static 'images/xi.ico' %}">
    <!--    bootstrap 3.X cdn-->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"
          integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->,
    <link rel="stylesheet" href="//at.alicdn.com/t/c/font_3592024_76c69hzfit.css">
    <style>

    </style>
    <script src="https://cdn.staticfile.org/jquery/3.6.1/jquery.min.js"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"
            integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd"
            crossorigin="anonymous"></script>
    <script src="{% static 'js/http.js' %}"></script>
    <!--title-->
    <title>
        {% block title %}
        {% endblock %}
    </title>
    <!--   css区域 -->
    {% block css %}
        {% endblock %}
</head>
<body>
<!--    导航-->
<dvi class="header">
    <nav class="navbar navbar-inverse">
        <div class="container-fluid">
            <!-- Brand and toggle get grouped for better mobile display -->
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
                        data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="{% url 'web:project_list' %}">Tracer</a>
            </div>

            <!-- Collect the nav links, forms, and other content for toggling -->
            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
                <ul class="nav navbar-nav">
                    <!--                    <li class="active"><a href="#">Link <span class="sr-only">(current)</span></a></li>-->

                     <li class="dropdown active">
                      {% if request.tracer.project %}
                      <a href="#" class="dropdown-toggle"
                         data-toggle="dropdown"
                         role="button"
                         aria-haspopup="true"
                         aria-expanded="false">{{request.tracer.project.name}}
                          <span class="caret"></span>
                      </a>
                      {% else%}
                         <a href="#" class="dropdown-toggle"
                         data-toggle="dropdown"
                         role="button"
                         aria-haspopup="true"
                         aria-expanded="false">项目列表
                          <span class="caret"></span>
                      </a>
                      {% endif %}
                      {% all_project_list  request %}
                    </li>
                    {% if request.tracer.project %}

                        {% menu_list request %}
                    {% endif %}
                </ul>

                <ul class="nav navbar-nav navbar-right">
                    <li><a href="javascript:;">工作台</a></li>
                    <li><a href="javascript:;">日历</a></li>
                    <li><a href="javascript:;"><i class="iconfont icon-bell"></i></a></li>
                    <li><a href="javascript:;"><i class="iconfont icon-yonghuziliao"></i></a></li>
                    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">{{request.tracer.user.username}} <span class="caret"></span></a>
                        <ul class="dropdown-menu"><li><a href="{% url 'web:index' %}" >回到官网</a></li><li><a href="javascript:;" >设   置</a></li><li><a href="javascript:;" id="logout">退出登录</a></li>
                        </ul>
                    </li>

                </ul>
            </div><!-- /.navbar-collapse -->
        </div><!-- /.container-fluid -->
    </nav>
</dvi>
<!--内容区域-->
{% block content %}
{% endblock%}

{% block js %}
{% endblock%}
<script>
    function logout(){
        let logoutDoc=document.querySelector('#logout')
        if(logoutDoc){
                logoutDoc.addEventListener('click',async ()=>{
                    const data=await fetch('{% url "web:logout" %}',{
                        method : 'GET'
                    })
                    const res=await data.json()
                    if(res.code==200){
                        window.location.href=res.data
                    }
                })
        }

    }
    logout()
</script>
</body>
</html>